# @author 菠萝吹雪
# @date 2024/4/19 15:48
import requests
from bs4 import BeautifulSoup

header = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 "
                  "Safari/537.36"}
text = requests.get("https://movie.douban.com/top250", headers=header).text
soup = BeautifulSoup(text, "html.parser")

# 打印第一个p标签
print(soup.find("p"))

# 打印所有p标签
# print(soup.find_all("p"))

# 打印符合class属性的所有p标签
all_title = soup.findAll("span", attrs={"class": "title"})
for title in all_title:
    # print(title)
    # print(title.text)
    text = title.text
    if "/" not in text:
        print(text)
